import 'package:fish_redux/fish_redux.dart';

import 'action.dart';
import 'state.dart';

Reducer<UserAccountViewState> buildReducer() {
  return asReducer(
    <Object, Reducer<UserAccountViewState>>{
      UserAccountViewAction.action: _onAction,
      UserAccountViewAction.onRefreshData: _onRefreshData,
    },
  );
}

UserAccountViewState _onAction(UserAccountViewState state, Action action) {
  final UserAccountViewState newState = state.clone();
  return newState;
}

UserAccountViewState _onRefreshData(
    UserAccountViewState state, Action action) {
  final UserAccountViewState newState = state.clone();
  newState.items.remove(action.payload);
  return newState;
}